#coding:utf-8

####################################################################
##  一，脚本语法说明：
##  [类型字段, 命令字段, 匹配结果字段, 超时时间字段, 错误等级字段]
##  1，类型字段：
##        0：AT命令
##        1：延迟
##        2：数据
##		  3：命令嵌套
##	2，命令字段：
##		1）AT命令
##		[0, 'AT命令字符串', '匹配结果', 超时时间（单位s）, 错误等级字段]
##		2）延迟命令
##		[1, 延迟时间（单位ms）, '', '', '']
##		3）发送数据
##		[2, '数据内容', '匹配结果', 超时时间(单位s), 错误等级字段]
##		4）命令嵌套
##		[2, 命令列表名称, '', '', 错误等级字段]
##	3，匹配结果字段：
##		1）单行字符串('string')：按照字符串查找方式，匹配AT返回中的某一行，如果匹配成功就认为命令执行成功
##		2) 单行正则表达式(Reg('reg')): 按照正则表达式匹配方式，匹配AT返回中某一行，如果匹配成功就认为命令执行成功
##		3）多行字符串(FullMatch('string_line1\r\nstring_line2')): 按照字符串查找方式，匹配AT返回中的多行，如果匹配成功就认为命令执行成功
##		4）多行正则表达式(ReMatch('reg1[\s\S]+reg2')): 按照正则表达式匹配方式，匹配AT返回的多行，如果匹配成功就认为命令执行成功
##	4，超时时间字段：
##		如果执行【命令字段】后没有匹配到【匹配结果字段】，就会等待超时，超时时间单位为s
##	5，错误等级字段
##		0：忽略该条命令匹配错误继续执行下一行
##		1：如果该条命令匹配错误就停止执行
####################################################################
sms = [
    [0,'AT+ICCID', ReMatch('89860439101880649976'), 10, 1],
    [0,'AT+CMGF=0', 'OK', 10, 1],
	[0,'AT+CSMP=17,11,0,0', 'OK', 10, 1],
	[0,'AT+CNMI=2,2', 'OK', 10, 1], 
    [0,'AT+CSCS="GSM"', 'OK', 10, 1],
    [0,'AT+CMGS=24', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500000BB4636BDA9CB6A8C52915\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,42\r\n[\s\S]+1600340047002d0053004d0053002d0054004500530054'), 10, 1],
    [0,'AT+CMGS=25', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500040B34472D534D532D54455354\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,42\r\n[\s\S]+1600340047002d0053004d0053002d0054004500530054'), 10, 1],
    [0,'AT+CMGS=36', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500081600340047002D0053004D0053002D0054004500530054\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,42\r\n[\s\S]+1600340047002d0053004d0053002d0054004500530054'), 10, 1],
    [0,'AT+CMGS=137', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500008CE8329BFD06DDDF72363904A21D5BD3E6B4452D4EA9A0986C46ABD96EB81C0C842EB3D96FD0FD2D67934341E19058341E9149E592D9743EA151E9945AB55EB1592D280692C940B3D90C44A3D168A05AAD56AB816C369BCD6603DD6EB7DBED7603E170381C0E87C38172B95C2E97CBE572207499CD7E8362B219AD06\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,160\r\n[\s\S]+00680065006c006c006f00200077006f0072006c00640021002000340047002d0053004d0053002d005400450053005400200031003200330034003500360037003800390030002000680065006c006c006f00200077006f0072006c00640021004100420043004400450046004700480049004a004b004c004d004e004f0050005100520053\r\n\r\n\+CMT:,160\r\n[\s\S]+005400550056005700580059005a002000310020003200320020003300330033002000340034003400340020003500350035003500350020003600360036003600360036002000370037003700370037003700370020003800380038003800380038003800380020003900390039003900390039003900390039002000680065006c006c006f\r\n\r\n\+CMT:,38\r\n[\s\S]+000310032003300340035'), 10, 1],   
    [0,'AT+CSCS="UCS2"', 'OK', 10, 1],
    [0,'AT+CMGS=24', FullMatch('>'), 5, 1], 
    [2,'0001000D81014698192060F500000BB4636BDA9CB6A8C52915\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,42\r\n[\s\S]+1600340047002d0053004d0053002d0054004500530054'), 10, 1], 
    [0,'AT+CMGS=25', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500040B34472D534D532D54455354\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,42\r\n[\s\S]+1600340047002d0053004d0053002d0054004500530054'), 10, 1],
    [0,'AT+CMGS=36', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500081600340047002D0053004D0053002D0054004500530054\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,42\r\n[\s\S]+1600340047002d0053004d0053002d0054004500530054'), 10, 1],
    [0,'AT+CMGS=137', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500008CE8329BFD06DDDF72363904A21D5BD3E6B4452D4EA9A0986C46ABD96EB81C0C842EB3D96FD0FD2D67934341E19058341E9149E592D9743EA151E9945AB55EB1592D280692C940B3D90C44A3D168A05AAD56AB816C369BCD6603DD6EB7DBED7603E170381C0E87C38172B95C2E97CBE572207499CD7E8362B219AD06\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,160\r\n[\s\S]+00680065006c006c006f00200077006f0072006c00640021002000340047002d0053004d0053002d005400450053005400200031003200330034003500360037003800390030002000680065006c006c006f00200077006f0072006c00640021004100420043004400450046004700480049004a004b004c004d004e004f0050005100520053\r\n\r\n\+CMT:,160\r\n[\s\S]+005400550056005700580059005a002000310020003200320020003300330033002000340034003400340020003500350035003500350020003600360036003600360036002000370037003700370037003700370020003800380038003800380038003800380020003900390039003900390039003900390039002000680065006c006c006f\r\n\r\n\+CMT:,38\r\n[\s\S]+000310032003300340035'), 10, 1],   
    [0,'AT+CSCS="IRA"', 'OK', 10, 1], 
    [0,'AT+CMGS=56', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F5000030B4636BDA9CB6A8C529151493CD6835DB0D97838182C221B1683C2293CA25B3E97C42A3D229B56ABD62B5\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,116\r\n[\s\S]+6000340047002d0053004d0053002d0054004500530054002000310032003300340035003600370038003900300020004100420043004400450046004700480049004a004b004c004d004e004f005000510052005300540055005600570058005a'), 10, 1],  
    [0,'AT+CMGS=25', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500040B34472D534D532D54455354\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,42\r\n[\s\S]+1600340047002d0053004d0053002d0054004500530054'), 10, 1],
    [0,'AT+CMGS=36', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500081600340047002D0053004D0053002D0054004500530054\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,42\r\n[\s\S]+1600340047002d0053004d0053002d0054004500530054'), 10, 1],
    [0,'AT+CMGS=137', FullMatch('>'), 5, 1],
    [2,'0001000D81014698192060F500008CE8329BFD06DDDF72363904A21D5BD3E6B4452D4EA9A0986C46ABD96EB81C0C842EB3D96FD0FD2D67934341E19058341E9149E592D9743EA151E9945AB55EB1592D280692C940B3D90C44A3D168A05AAD56AB816C369BCD6603DD6EB7DBED7603E170381C0E87C38172B95C2E97CBE572207499CD7E8362B219AD06\x1a', ReMatch('\+CMGS: \d+\r\n\r\nOK\r\n\r\n\+CMT:,160\r\n[\s\S]+00680065006c006c006f00200077006f0072006c00640021002000340047002d0053004d0053002d005400450053005400200031003200330034003500360037003800390030002000680065006c006c006f00200077006f0072006c00640021004100420043004400450046004700480049004a004b004c004d004e004f0050005100520053\r\n\r\n\+CMT:,160\r\n[\s\S]+005400550056005700580059005a002000310020003200320020003300330033002000340034003400340020003500350035003500350020003600360036003600360036002000370037003700370037003700370020003800380038003800380038003800380020003900390039003900390039003900390039002000680065006c006c006f\r\n\r\n\+CMT:,38\r\n[\s\S]+000310032003300340035'), 10, 1],    
]
